package com.xbongbong.saas.enums.business;

import com.xbongbong.i18n.util.I18nMessageUtil;
import com.xbongbong.paas.enums.FieldTypeEnum;
import com.xbongbong.saas.enums.SetTypeEnum;
import com.xbongbong.saas.enums.ShowTypeEnum;
import lombok.Getter;

/**
 * 月报枚举类
 * 注意：
 * 1.强制：attr的值一经刷入数据库，就不允许改变（比如text_1不允许改为text_12，即使不冲突，因为后续会根据枚举中saasAttr和attr的对应关系来获取解释）
 * 2.强制：属性修饰必须为private，比如private String attr（后续反射获取属性时会依赖到）
 * 3.强制：属性的名称必须和FieldAttrEntity实体中的属性一致，不然无法赋值过去
 *
 * @author long.rao
 * @date 2019/1/17 19:35
 */
@Getter
public enum WorkReportMonthlyEnum {
    // 月报枚举属性
    // 基础信息
    BASE_INFO("other_1", "enum.workReportMonthly.attrName.base_info", "baseInfo", FieldTypeEnum.SEPARATOR.getType(), SetTypeEnum.DISABLE_REPEAT.getCode(), 1, 0, ShowTypeEnum.EDIT_DETAIL.getCode(), 10000, 1, 0),
    TYPE(WorkReportFieldEnum.TYPE.getAttr(), "enum.workReportMonthly.attrName.type", "type", FieldTypeEnum.COMBO.getType(), 1, 0, 0, ShowTypeEnum.ALL.getCode(), 9990, 1, 1),
    REPORT_DATE(WorkReportFieldEnum.REPORT_DATE.getAttr(), "enum.workReportMonthly.attrName.report_date", "reportDate", FieldTypeEnum.DATETIME.getType(), 1, 1, 0, ShowTypeEnum.ALL.getCode(), 9980, 1, 1),
    APPROVED_PEOPLE(WorkReportFieldEnum.APPROVED_PEOPLE.getAttr(), "enum.workReportMonthly.attrName.approved_people", "approvedPeople", FieldTypeEnum.TEXT.getType(), 1, 0, 0, ShowTypeEnum.EDIT.getCode(), 9970, 1, 1),
    CC(WorkReportFieldEnum.CC.getAttr(), "enum.workReportMonthly.attrName.cc", "cc", FieldTypeEnum.USER_GROUP.getType(), 1, 1, 0, ShowTypeEnum.EDIT.getCode(), 9960, 1, 0),
    THIS_STATISTIC(WorkReportFieldEnum.THIS_STATISTIC.getAttr(), "enum.workReportMonthly.attrName.this_statistic", "thisStatistic", FieldTypeEnum.TEXTAREA.getType(), 3, 0, 0, ShowTypeEnum.EDIT_DETAIL.getCode(), 9940, 1, 0),
    CONTENT(WorkReportFieldEnum.CONTENT.getAttr(), "enum.workReportMonthly.attrName.content", "content", FieldTypeEnum.TEXTAREA.getType(), 3, 1, 0, ShowTypeEnum.EDIT_DETAIL.getCode(), 9930, 1, 1),
    IMAGES(WorkReportFieldEnum.IMAGE.getAttr(), "enum.workReportMonthly.attrName.images", "images", FieldTypeEnum.IMAGE.getType(), 3, 1, 0, ShowTypeEnum.EDIT_DETAIL.getCode(), 9920, 1, 0),
    THIS_PLAN(WorkReportFieldEnum.THIS_PLAN.getAttr(), "enum.workReportMonthly.attrName.this_plan", "thisPlan", FieldTypeEnum.SWITCH_TEXT.getType(), 1, 0, 0, ShowTypeEnum.EDIT_DETAIL.getCode(), 9915, 1, 0),
    NEXT_PLAN(WorkReportFieldEnum.NEXT_PLAN.getAttr(), "enum.workReportMonthly.attrName.next_plan", "nextPlan", FieldTypeEnum.SUB_FORM.getType(), 3, 1, 0, ShowTypeEnum.EDIT_DETAIL.getCode(), 9910, 1, 0),
    // 系统信息
    SYSTEM_INFO("other_2", "enum.workReportMonthly.attrName.system_info", "systemInfo", FieldTypeEnum.SEPARATOR.getType(), SetTypeEnum.DISABLE_REPEAT.getCode(), 1, 0, ShowTypeEnum.EDIT_DETAIL.getCode(), 9900, 1, 0),
    CREATOR_ID(WorkReportFieldEnum.CREATOR_ID.getAttr(), "enum.workReportMonthly.attrName.creator_id", "creatorId", FieldTypeEnum.CREATORID.getType(), 1, 1, 0, ShowTypeEnum.ALL.getCode(), 9890, 1, 0),
    ADD_TIME(WorkReportFieldEnum.ADD_TIME.getAttr(), "enum.workReportMonthly.attrName.add_time", "addTime", FieldTypeEnum.ADDTIME.getType(), 1, 1, 0, ShowTypeEnum.ALL.getCode(), 9880, 1, 0),
    UPDATE_TIME(WorkReportFieldEnum.UPDATE_TIME.getAttr(), "enum.workReportMonthly.attrName.update_time", "updateTime", FieldTypeEnum.UPDATETIME.getType(), 1, 1, 0, ShowTypeEnum.ALL.getCode(), 9870, 1, 0),
    // 逻辑字段
    REVIEWER(WorkReportFieldEnum.REVIEWER.getAttr(), "enum.workReportMonthly.attrName.reviewer", "reviewer", FieldTypeEnum.TEXT.getType(), 1, 1, 1, ShowTypeEnum.DETAIL.getCode(), 9860, 0, 0),
    IS_RESSUE(WorkReportFieldEnum.IS_RESSUE.getAttr(), "enum.workReportMonthly.attrName.is_ressue", "isRessue", FieldTypeEnum.COMBO.getType(), 1, 1, 1, ShowTypeEnum.DETAIL.getCode(), 9850, 0, 0),;

    /**
     * 英文名称
     */
    private String attr;
    /**
     * 中文名称
     */
    private String attrName;
    /**
     * 对应saas中的attr
     */
    private String saasAttr;
    /**
     * 字段类型，详见
     *
     * @see com.xbongbong.paas.enums.FieldTypeEnum
     */
    private Integer fieldType;
    /**
     * 重命名、判重、启用必填等权限
     * 1.重命名+字段权限
     * 2.重命名+字段权限+查重
     * 3.重命名+字段权限+启用、必填
     * 4.重命名+字段权限+查重+启用、必填
     * 注：pro中启用和必填是同一个权限，同时启用或同时关闭
     */
    private Integer setType;
    /**
     * 模板设计阶段字段是否允许编辑
     * 1：允许编辑
     * 0：不允许编辑
     */
    private Integer designEditable;
    /**
     * 字段是否显示在模板设计界面
     * 1：不显示
     * 0：显示
     */
    private Integer editHide;
    /**
     * 字段在各个界面（新建、编辑、列表、详情）的展现形式
     * 详见
     *
     * @see com.xbongbong.saas.enums.ShowTypeEnum
     */
    private Integer showType;
    /**
     * 字段在模板设计界面的排序
     * 建议不要用连续的数字，可以用等差数列，以防以后在两个字段之间加入新字段
     */
    private Integer sort;
    /**
     * 字段在各个界面是否可见(启用)
     * 1：可见
     * 0：不可见
     * 注：字段在具体页面的可见性需要用属性和showType联合判断，在visible=1的情况下判断showType
     */
    private Integer visible;
    /**
     * 字段是否必填
     * 1：必填
     * 0：不必填
     */
    private Integer required;

    WorkReportMonthlyEnum(String attr, String attrName, String saasAttr, Integer fieldType, Integer setType, Integer designEditable,
                          Integer editHide, Integer showType, Integer sort, Integer visible, Integer required) {
        this.attr = attr;
        this.attrName = attrName;
        this.saasAttr = saasAttr;
        this.fieldType = fieldType;
        this.setType = setType;
        this.designEditable = designEditable;
        this.editHide = editHide;
        this.showType = showType;
        this.sort = sort;
        this.visible = visible;
        this.required = required;
    }

    public String getAttrName() {
        return I18nMessageUtil.getMessage(attrName);
    }

    public static String getI18nValue(String value) {
        return I18nMessageUtil.getMessage(value);
    }
}
